﻿@using MudExtensions.Enums
@using HardHatCore.ApiModels.Shared
@using HardHatCore.HardHatC2Client.Plugin_Management
@inherits ImplantCreation

<MudStep Icon="@MaterialDesignIcons.Normal.PlusNetwork" Title="Modules">
    <ChildContent>
        <MudForm @ref="ImpModuleForm" @bind-IsValid="@success">
            <MudTransferList Class="d-flex align-center justify-center" MaxItems="10" T="string" @bind-StartCollection="ImpModuleList" EndCollection="selectedImpModuleList"  Color="Color.Primary"
                             StyleListCommon="background-color: var(--mud-palette-background-grey); width: 300px" MultiSelection="true" SelectAllType="SelectAllType.Buttons"
                             OrderFunc="@OrderCheckFunc" ButtonVariant="Variant.Text"
                             AllowDoubleClick="false" />
           
            @if (ModuleOptionsUI is not null)
            {
                @ModuleOptionsUI 
            }
        </MudForm>
    </ChildContent>
</MudStep>

@code {
    [Parameter,EditorRequired]
    public MudForm ImpModuleForm { get; set; }

    [Parameter, EditorRequired]
    public ICollection<string> ImpModuleList { get; set; }

    [Parameter,EditorRequired]
    public Func<ICollection<string>, ICollection<string>> OrderCheckFunc { get; set; }

    private RenderFragment ModuleOptionsUI { get; set; }


    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        var implantUiPlugin = PluginService.GetImplantCreationPlugin(ImplantName);
        if (implantUiPlugin != null)
        {
            ModuleOptionsUI = implantUiPlugin.GetModuleOptionsUI();
        }
    }
}
